package com.ynu.appuser.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ynu.appuser.mapper.PushTemplateMapper;
import com.ynu.appuser.domain.push.PushTemplate;
import com.ynu.appuser.service.IPushTemplateService;

/**
 * 推送消息模板Service业务层处理
 *
 * @author ruoyi
 * @date 2022-12-01
 */
@Service
public class PushTemplateServiceImpl implements IPushTemplateService
{
    @Autowired
    private PushTemplateMapper pushTemplateMapper;

    /**
     * 查询推送消息模板
     *
     * @param id 推送消息模板主键
     * @return 推送消息模板
     */
    @Override
    public PushTemplate selectPushTemplateById(Long id)
    {
        return pushTemplateMapper.selectPushTemplateById(id);
    }

    /**
     * 查询推送消息模板列表
     *
     * @param pushTemplate 推送消息模板
     * @return 推送消息模板
     */
    @Override
    public List<PushTemplate> selectPushTemplateList(PushTemplate pushTemplate)
    {
        return pushTemplateMapper.selectPushTemplateList(pushTemplate);
    }

    /**
     * 新增推送消息模板
     *
     * @param pushTemplate 推送消息模板
     * @return 结果
     */
    @Override
    public int insertPushTemplate(PushTemplate pushTemplate)
    {
        pushTemplate.setUpdateTime(DateUtils.getNowDate());
        Long userId = SecurityUtils.getLoginUser().getUserId();
        pushTemplate.setCreator(userId);
        pushTemplate.setUpdator(userId);
        return pushTemplateMapper.insertPushTemplate(pushTemplate);
    }

    /**
     * 修改推送消息模板
     *
     * @param pushTemplate 推送消息模板
     * @return 结果
     */
    @Override
    public int updatePushTemplate(PushTemplate pushTemplate)
    {
        pushTemplate.setUpdateTime(DateUtils.getNowDate());
        Long userId = SecurityUtils.getLoginUser().getUserId();
        pushTemplate.setUpdator(userId);
        return pushTemplateMapper.updatePushTemplate(pushTemplate);
    }

    /**
     * 批量删除推送消息模板
     *
     * @param ids 需要删除的推送消息模板主键
     * @return 结果
     */
    @Override
    public int deletePushTemplateByIds(Long[] ids)
    {
        return pushTemplateMapper.deletePushTemplateByIds(ids);
    }

    /**
     * 删除推送消息模板信息
     *
     * @param id 推送消息模板主键
     * @return 结果
     */
    @Override
    public int deletePushTemplateById(Long id)
    {
        return pushTemplateMapper.deletePushTemplateById(id);
    }
}
